/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package edu.yonsei.iwb.smarttv.ner;

//import java.util.Hashtable;
import java.util.LinkedHashMap;
import java.util.Vector;
import org.apache.lucene.document.Document;
import org.apache.lucene.search.Explanation;

/**
 *
 * @author JDK
 */
public class QueryPartition {

    private double sum_of_partition_score;
    private double final_partition_score;
    private Vector<Vector<String>> query_vector_terms = new Vector<Vector<String>>();
    private LinkedHashMap<String, Double> score = new LinkedHashMap<String, Double>();
    private LinkedHashMap<String, Vector<Explanation>> explanation = new LinkedHashMap<String, Vector<Explanation>>();
    private LinkedHashMap<String, Vector<Document>> document = new LinkedHashMap<String, Vector<Document>>();

    public QueryPartition() {
        this.sum_of_partition_score = 0;
        this.final_partition_score = 0;
    }

    public void addQueryVectorSet(Vector<String> v) {
        this.query_vector_terms.add(v);
    }

    public void putPartitionExplanation(String query, Vector e) {
        this.explanation.put(query, e);
    }

    public void putPartitionDocumnment(String query, Vector doc) {
        this.document.put(query, doc);
    }

    public void putPartitionScore(String query, double score) {
        this.sum_of_partition_score += score;
        this.score.put(query, score);
    }

    public double getPartitionScore() {
        this.final_partition_score = this.sum_of_partition_score / this.query_vector_terms.size();
        return final_partition_score;
    }

    public double getQueryScore(String query) {
        return score.get(query);
    }

    public Vector<Document> getResultDocument(String query) {
        return document.get(query);
    }

    public Vector<Explanation> getResultExplanation(String query) {
        return explanation.get(query);
    }

    public Vector<Vector<String>> getQueryVectorSet() {
        return this.query_vector_terms;
    }

    public String toStringQueryVector() {
        StringBuffer sb = new StringBuffer();
        sb.append("{");
        for (int i = 0; i < query_vector_terms.size(); i++) {
            Vector<String> v = query_vector_terms.get(i);
            sb.append("{");
            for (int j = 0; j < v.size(); j++) {
                sb.append(v.get(j));
                if (j != (v.size() - 1)) {
                    sb.append(", ");
                }
            }
            sb.append("}");
            if (i != (query_vector_terms.size() - 1)) {
                sb.append(", ");
            }
        }
        sb.append("}");
        return sb.toString();
    }

    @Override
    public String toString() {
        StringBuffer sb = new StringBuffer();
        sb.append(this.toStringQueryVector() + ", " + this.final_partition_score);
        return sb.toString();
    }
}
